<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 2.创建路由链接 -->
        <router-link to="/login">登录</router-link>
        <router-link to="/register">注册</router-link>
        <!-- 3.创建路由占位符 -->
        <router-view></router-view>
    </div>
    <!-- 1.引入相关的js文件 -->
    <script src="../lib/vue_2.5.22.js"></script>
    <script src="../lib/vue-router_3.0.2.js"></script>
    <script>
        // 4.创建路由组件
        var Login = {
            template: `
            <div>
                <h1>呀！我登录了哦</h1>
            </div>
        `,
        };
        var Register = {
            template: `
            <div>
                <h1>啊！我注册了哦</h1>
            </div>
        `,
        };
        // 创建路由实例对象
        var router = new VueRouter({
            routes: [{
                path: '/',
                redirect: '/login',
            }, {
                path: '/login',
                component: Login,
            }, {
                path: '/register',
                component: Register,
            }, ],
        });
        var vm = new Vue({
            el: '#app',
            data: {},
            // 6.将路由挂载到vm根实例上
            router,
        });
    </script>
</body>

</html>